home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / FLUSHINP.C < prev    next >
Text File  |  1992-11-21  |  2KB  |  66 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef flushinp
  4.  
  5. #ifndef        NDEBUG
  6. char *rcsid_flushinp = "$Header: c:/curses/portable/RCS/flushinp.c%v 2.0 1992/11/15 03:28:52 MH Rel $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   flushinp()   - discard type-ahead
  15.  
  16.   X/Open Description:
  17.        Throws away any type-ahead that has been typed by the user and
  18.        has not yet been read by the program.
  19.  
  20.   PDCurses Description:
  21.        If the PDCurses library is compiled under DOS with the FAST_VIDEO
  22.        define true, then we will poke the BIOS keyboard buffer head and
  23.        tail pointers, resetting the typeahead.
  24.  
  25.        If this is not true, then we will be unable to reliably flush
  26.        the typeahead.
  27.  
  28.   X/Open Return Value:
  29.        The flushinp() function returns OK on success and ERR on error.
  30.  
  31.   X/Open Errors:
  32.        No errors are defined for this function.
  33.  
  34.   Portability:
  35.        PDCurses        int flushinp( void );
  36.        X/Open Dec '88  int flushinp( void );
  37.        BSD Curses      int flushinp( void );
  38.        SYS V Curses    int flushinp( void );
  39.  
  40. **man-end**********************************************************************/
  41.  
  42. int    flushinp(void)
  43. {
  44. extern int     c_pindex;               /* putter index */
  45. extern int     c_gindex;               /* getter index */
  46. extern int     c_ungind;               /* wungetch() push index */
  47.  
  48.  
  49. #if defined(DOS) && defined(FAST_VIDEO)
  50.        short  *KB_HEAD = (short *) 0x041aL;    /* 40:1A  BIOS KB head  */
  51.        short  *KB_TAIL = (short *) 0x041cL;    /* 40:1A  BIOS KB tail  */
  52.  
  53.        *KB_HEAD = *KB_TAIL;            /* Force the BIOS kbd buf       */
  54.                                        /* head/tail pointers to be the */
  55.                                        /* same...  Real nasty trick... */
  56.  
  57. #endif
  58. #ifdef OS2
  59.        KbdFlushBuffer(0);
  60. #endif
  61.        c_gindex = 1;                   /* set indices to kill buffer    */
  62.        c_pindex = 0;
  63.        c_ungind = 0;                   /* clear c_ungch array           */
  64.        return( OK );
  65. }
  66.